﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using ASPNETPerformance.App_BusinessLogic.Helpers;
using ASPNETPerformance.App_BusinessLogic.Navigation;
using ASPNETPerformance.App_BusinessLogic.SEO;
using ASPNETPerformance.App_BusinessLogic.Utils;

namespace ASPNETPerformance.App_BusinessLogic.BasePages {
    public class BasePage : System.Web.UI.Page {
        private NavigationClass navigation = new NavigationClass();
        public NavigationClass Navigation {
            get {
                return navigation;
            }
        }

        protected override void OnPreRender( EventArgs e ) {
            // Note: Replace sinorcaish-screen.css,CustomStyles.css
            if ( CommonHelper.GetCookieBool( "IsEnableDefaultJsAndCss" ) ) {
                if ( File.Exists( HttpContext.Current.Request.PhysicalApplicationPath + "_assets\\css\\Public.all.css" ) ) {
                    SEOHelper.AddStylesheetInclude( this, "~/_assets/css/Public.all.css" );
                }
                else {
                    BindCss();
                }
                if ( File.Exists( HttpContext.Current.Request.PhysicalApplicationPath + "_assets\\js\\Public.all.js" ) ) {
                    SEOHelper.AddJavaScriptInclude( this, "~/_assets/js/Public.all.js" );
                }
                else {
                    BindJs();
                }
            }
            else {
                BindCss();
                BindJs();
            }

            base.OnPreRender( e );
        }

        public void BindCss() {
            SEOHelper.AddStylesheetInclude( this, "~/_assets/css/core.css" );
            SEOHelper.AddStylesheetInclude( this, "~/_assets/css/grid.css" );
            SEOHelper.AddStylesheetInclude( this, "~/_assets/css/round.css" );
            SEOHelper.AddStylesheetInclude( this, "~/_assets/css/sinorcaish-screen.css" );
            SEOHelper.AddStylesheetInclude( this, "~/_assets/css/CustomStyles.css" );
        }

        public void BindJs() {
            SEOHelper.AddJavaScriptInclude( this, "~/_assets/js/jquery-1.4.4.min.js" );
            SEOHelper.AddJavaScriptInclude( this, "~/_assets/js/public.js" );
        }
    }
}